package com.cn.zengzeng.spbzengzeng.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @Description:
 * @Author: zhangzengzeng
 * @Date: 2022/3/9 11:02
 */
@Slf4j
@Configuration
@EnableSwagger2
@EnableKnife4j
public class SwaggerConfiguration  {

    public static final String HOST = "127.0.0.1";

    @Bean(value = "testApi")
    public Docket testApiBean() {
        return new Docket(DocumentationType.SWAGGER_2)
                .host(HOST)
                .useDefaultResponseMessages(false)
                .groupName("testApi")
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.cn.zengzeng.spbzengzeng.controller.test"))
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                .paths(PathSelectors.any())
                .build();

    }
    @Bean(value = "kafkaApi")
    public Docket kafkaApiBean() {
        return new Docket(DocumentationType.SWAGGER_2)
                .enable(true)
                .host(HOST)
                .useDefaultResponseMessages(false)
                .groupName("kafkaApi")
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.cn.zengzeng.spbzengzeng.controller.queue"))
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                .paths(PathSelectors.any())
                .build();

    }
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .description("zengzeng集成测试文档")
                .contact(new Contact("Mir.z","www.wolaos.cn","vvip010@163.com"))
                .version("v1.1.0")
                .title("API文档")
                .build();
    }
}
